﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity;

namespace Data
{
    /// <summary>
    /// 公用后台数据操作规范
    /// 为了与之前设计的程序兼容，所有保留本接口
    /// 以后开发数据操作规范将以IRepository为准　
    /// </summary>
    public interface IBackgroundRepository<TEntity> where TEntity : EntityBase
    {
        /// <summary>
        ///  更新实体
        /// </summary>
        /// <param name="entity"></param>
        void Update(TEntity entity);
        /// <summary>
        /// [批量]更新实体
        /// </summary>
        /// <param name="list"></param>
        void Update(IList<TEntity> list);

        /// <summary>
        ///  插入实体
        /// </summary>
        void Insert(TEntity entity);

        /// <summary>
        ///  [批量]插入实体
        /// </summary>
        void Insert(IList<TEntity> list);

        /// <summary>
        /// 插入记录并返回刚刚立即插入的状态视图
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        TEntity InsertGetIDENTITY(TEntity entity);

        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="entity"></param>
        void Delete(TEntity entity);

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="list"></param>
        void Delete(IList<TEntity> list);


        /// <summary>
        /// 返回默认结果集
        /// </summary>
        /// <returns></returns>
        IQueryable<TEntity> GetModel();

        /// <summary>
        /// 通过主键，得到实体
        /// 始终从数据库中获取数据
        /// </summary>
        /// <param name="keyValues"></param>
        /// <returns></returns>
        TEntity Find(params object[] keyValues);

    }
}
